using AppToolKit.Data;
using AppToolKit.Model;
using System;
namespace AppToolKit.Business
{
	public class BusinessFactory : IBusinessFactory
	{
		private BusinessSupport suppor_;
		private IDataAccessObjectFacotry daoFactory_;
		public BusinessSupport Support
		{
			get
			{
				return this.suppor_;
			}
			set
			{
				this.suppor_ = value;
			}
		}
		public IDataAccessObjectFacotry DaoFactory
		{
			get
			{
				return this.daoFactory_;
			}
			set
			{
				this.daoFactory_ = value;
			}
		}
		public IBusiness<T> GetBusiness<T, F>() where T : class, IEntity where F : IEntityFactory<T>
		{
			return new DefaultBusiness<T>
			{
				Dao = this.daoFactory_.Create<T>(),
				Factory = Activator.CreateInstance<F>(),
				Support = this.suppor_
			};
		}
		public IBusiness<T> GetBusiness<T>() where T : class, IEntity
		{
			return new DefaultBusiness<T>
			{
				Support = this.suppor_,
				Dao = this.daoFactory_.Create<T>()
			};
		}
	}
}
